
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.SessionState;
using System.Web;

namespace ScrewTurn.Wiki {

	/// <summary>
	/// Exposes in a strongly-typed fashion the Session variables.
	/// </summary>
	public static class SessionFacade {

		/// <summary>
		/// Gets the current Session object.
		/// </summary>
		private static HttpSessionState Session {
			get { return HttpContext.Current.Session; }
		}

		/// <summary>
		/// Gets or sets the Login Key.
		/// </summary>
		public static string LoginKey {
			get { return Session != null ? (string)Session["LoginKey"] : null; }
			set { if(Session != null) Session["LoginKey"] = value; }
		}

		/// <summary>
		/// Gets or sets the Username.
		/// </summary>
		public static string Username {
			get { return Session != null ? (string)Session["Username"] : null; }
			set { Session["Username"] = value; }
		}

		/// <summary>
		/// Gets or sets a value indicating whether the User is an Administrator.
		/// </summary>
		public static bool Admin {
			get {
				if(LoginKey != null && Session != null)
					return (bool)Session["Admin"];
				else return false;
			}
			set { if(Session != null) Session["Admin"] = value; }
		}

		/// <summary>
		/// Gets or sets the Admin View.
		/// </summary>
		public static int AdminView {
			get {
				if(Session != null && Session["AdminView"] != null)
					return (int)Session["AdminView"];
				else return -1;
			}
			set { if(Session != null) Session["AdminView"] = value; }
		}

		/// <summary>
		/// Gets or sets the CAPTCHA string.
		/// </summary>
		public static string CaptchaString {
			get { return Session != null ? (string)Session["CaptchaString"] : null; }
			set { if(Session != null) Session["CaptchaString"] = value; }
		}

		/// <summary>
		/// Gets or sets the Breadcrumbs Manager.
		/// </summary>
		public static BreadcrumbsManager Breadcrumbs {
			get { return Session != null ? (BreadcrumbsManager)Session["Breadcrumbs"] : null; }
			set { if(Session != null) Session["Breadcrumbs"] = value; }
		}

	}

}
